#pragma once

#include <stdio.h>

namespace prototype {
    
/// @brief 需要从A的实例得到一份与A内容相同，但是又互不干扰的实例

/// @brief 抽象原型类
class AbstractPrototype {
public:
    AbstractPrototype() = default;
	virtual ~AbstractPrototype() {}

	virtual AbstractPrototype* clone() = 0;
};

/// @brief 具体原型类
class ConcretePrototype : public AbstractPrototype {
public:
	ConcretePrototype() = default;
	~ConcretePrototype() {}

	AbstractPrototype* clone() {
        return new ConcretePrototype(*this);
    }

private:
	ConcretePrototype(const ConcretePrototype& other) {
        fprintf(stderr, "ConcretePrototype copy construct!\n");
    }
};

} // namespace prototype

void Test_02_prototype_impl_1() {
    printf("-------------------- %s --------------------\n", __FUNCTION__);
    prototype::AbstractPrototype* ptr_a = new prototype::ConcretePrototype();
    prototype::AbstractPrototype* ptr_b = ptr_a->clone();

    delete ptr_a;
    delete ptr_b; 
}

// -------------------- Test_02_prototype_impl_1 --------------------
// ConcretePrototype copy construct!